package conceptmaniax.hotelapp.activities;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import com.google.android.maps.MapActivity;

import conceptmaniax.hotelapp.config.Constants;
import conceptmaniax.hotelapp.util.GeneralUtils;

public class RouteMapActivity extends MapActivity {
    
    @Override
    public void onCreate(final Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	
    	// Parse String array from previous intent
    	final String[] location = getIntent().getExtras().getStringArray("LOCATION");
    	
    	// go to Google Maps
    	goToGoogleMaps(location);
    }
    
    private void goToGoogleMaps(final String location[]) {
    	final Uri uri =Uri.parse("http://maps.google.com/maps?&saddr=" +location[0] +"," +location[1] +"&daddr=" +location[2]+"," +location[3]);
    	final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    	if (GeneralUtils.isAppInstalled(this, Constants.GOOGLE_MAPS_APP)) {
    		intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
    	}
    	startActivity(intent);
    	finish();
    }

    @Override
    protected boolean isRouteDisplayed() {
    	return false;
    }
}
